/**
* @author:kellen
* @contact:xiekellen@hotmail.com
* @company:achivo-gz
* @created on:
* @modified on:
*/

package com.sasis.dao.ibatis;

import java.util.List;

import com.sasis.dao.ibatis.BaseDaoiBATIS;
import com.sasis.model.FlightTransferHotel;
import com.sasis.dao.FlightTransferHotelDao;

import org.springframework.orm.ObjectRetrievalFailureException;

public class FlightTransferHotelDaoiBatis extends BaseDaoiBATIS implements FlightTransferHotelDao {

    /**
     * @see com.sasis.dao.FlightTransferHotelDao#getFlightTransferHotels(com.sasis.model.FlightTransferHotel)
     */
    public List getFlightTransferHotels(final FlightTransferHotel flightTransferHotel) {
          return getSqlMapClientTemplate().queryForList("getFlightTransferHotels", flightTransferHotel);
    }

    /**
     * @see com.sasis.dao.FlightTransferHotelDao#getFlightTransferHotel(Integer id)
     */
    public FlightTransferHotel getFlightTransferHotel(Integer id) {
        FlightTransferHotel flightTransferHotel = (FlightTransferHotel) getSqlMapClientTemplate().queryForObject("getFlightTransferHotel", id);

        //if (flightTransferHotel == null) {
            //throw new ObjectRetrievalFailureException(FlightTransferHotel.class, id);
        //}

        return flightTransferHotel;
    }

    /**
     * @see com.sasis.dao.FlightTransferHotelDao#saveFlightTransferHotel(FlightTransferHotel flightTransferHotel)
     */    
    public int saveFlightTransferHotel(final FlightTransferHotel flightTransferHotel) {
        Integer id = flightTransferHotel.getId();
        // check for new record
        if (id == null) {
            id = (Integer) getSqlMapClientTemplate().insert("addFlightTransferHotel", flightTransferHotel);
        } else {
            getSqlMapClientTemplate().update("updateFlightTransferHotel", flightTransferHotel);
        }
        if( id == null ) {
            throw new ObjectRetrievalFailureException(FlightTransferHotel.class, id);
        }
        return id.intValue();
    }

    /**
     * @see com.sasis.dao.FlightTransferHotelDao#removeFlightTransferHotel(Integer id)
     */
    public void removeFlightTransferHotel(FlightTransferHotel flightTransferHotel) {
        getSqlMapClientTemplate().update("deleteFlightTransferHotel",  flightTransferHotel);
    }
    
    public void deleteFlightTransferHotel(FlightTransferHotel flightTransferHotel){
    	getSqlMapClientTemplate().update("deleteByFlightTransferHotelId",  flightTransferHotel);
    }
}
